{% load staticfiles %}
<!--atsystem-->
<!DOCTYPE html>
<html>
    
    <head>
        <title>File Copy</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
                <link href="{% static 'bootstrap/css/bootstrap.min.css' %}" rel="stylesheet" media="screen">
        <link href="{% static 'bootstrap/css/bootstrap-responsive.min.css' %}" rel="stylesheet" media="screen">
        <link href="{% static 'assets/styles.css' %}" rel="stylesheet" media="screen">
        <link href="{% static 'assets/DT_bootstrap.css' %}" rel="stylesheet" media="screen">
        <script src="{% static 'vendors/modernizr-2.6.2-respond-1.1.0.min.js' %}"></script>  

        <script src="{% static 'artDialog/lib/jquery-1.10.2.js'%}"></script>
        <link href="{% static 'artDialog/css/ui-dialog.css'%}" rel="stylesheet">
        <script src="{% static 'artDialog/dist/dialog-min.js'%}"></script>
	<link rel="stylesheet" href="{%static 'zTree_v3-master/css/demo.css' %}" type="text/css">
        <link rel="stylesheet" href="{%static 'zTree_v3-master/css/zTreeStyle/zTreeStyle.css' %}" type="text/css">
        <script type="text/javascript" src="{%static 'zTree_v3-master/js/jquery-1.4.4.min.js' %}"></script>
        <script type="text/javascript" src="{%static 'zTree_v3-master/js/jquery.ztree.core.js' %}"></script>
        <script type="text/javascript" src="{%static 'zTree_v3-master/js/jquery.ztree.excheck.js' %}"></script>
        <script type="text/javascript" src="{%static 'zTree_v3-master/js/jquery.ztree.exedit.js' %}"></script>


    </head>
    <body>
                        <div class="block">
                            <div class="navbar navbar-inner block-header">
                                <div class="muted pull-left">File Copy</div>
                            </div>
                            <div class="block-content collapse in">
	                                <div class="span12">
        <div class="zTreeDemoBackground left">
        <ul id="treeDemo" class="ztree"></ul>
        </div>
         </div>
          </div>
<form action="#" id="form_sample_1" class="form-horizontal"> 
            <fieldset>
                     <label class="control-label">Abs Path<span class="required">*</span></label>
                      <div class="controls">
                          <input type="text" id="path"  name="path" data-required="1" class="span6 m-wrap"/>
                            <span class="help-block">Absolute full path of the target file !   e.g: /usr/loca/path/text.sh </span>
                      </div>
         <div class="form-actions">
          <a id = "btn1"  onclick="get_data()"  class="btn btn-primary ">Execute</a>
          <a id = "btn_cancel"  class="btn tooltip-bottom ">Cancel</a>
         </div>
 </fieldset>
</form>  
        </div>



    </body>

</html>

  <SCRIPT LANGUAGE="JavaScript">
        function myOnCheck(event, treeId, treeNode) {
		var nodes=treeNode.getPath();
		var n_array = new Array()
		var str = ''
		for (i=0;i<nodes.length;i++)
			{
			str += '/'+nodes[i]['name'];
			}
		window.data=str;
		};
        var setting = {	
	callback: {
		onClick: myOnCheck
	},

	check: {
		enable: false,
		chkStyle: "checkbox",
		chkboxType: { "Y": "p", "N": "s" }
		} 
	}; 
          
	var zNodes = {{file_dict|safe}}
 $(document).ready(function(){
                 $.fn.zTree.init($("#treeDemo"), setting, zNodes);
                });
	
function get_data(){
var array2=new Array()
array2.push("{{hosts}}")
var s_file=window.data;
array2.push(s_file)
var text=$("#path").val();
array2.push(text)
$.post('/admin/file_copy/cp_exec/',
   	{
      'arraydata':JSON.stringify(array2)
  	},
   function(data){
	var d = dialog({
    	title: '欢迎',
    	content: data
	});
	d.show();
//  alert(data);
      });
}

$("#btn_cancel").click(function(){
            window.close();
            });


</SCRIPT>
